package cn.edu.scau.nursingcenter.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.scau.nursingcenter.dao.RehabilitationRepository;
import cn.edu.scau.nursingcenter.entiry.Rehabilitation;
import cn.edu.scau.nursingcenter.service.RehabilitationService;
/**
 * 业务逻辑层接口实现类RehabilitationServiceImpl
 * @author feng
 *
 */
@Service
public class RehabilitationServiceImpl implements RehabilitationService{

	@Autowired
	private RehabilitationRepository rehabilitationRepository;
	/**
	  * 显示所有计划
	 * @return
	 */
	@Override
	public List<Rehabilitation> selectAll() {
		return rehabilitationRepository.findAll();
	}

	/**
	  * 新增康复计划
	 * @param rehabilitation对象
	 * @return
	 */
	@Override
	public Rehabilitation insert(Rehabilitation rehabilitation) {
		
		return rehabilitationRepository.save(rehabilitation);
	}

	/**
	 * 修改康复计划
	 * @param rehabilitation对象
	 * @return
	 */
	@Override
	public Rehabilitation update(Rehabilitation rehabilitation) {
		
		return rehabilitationRepository.save(rehabilitation);
	}

	/**
	 * 根据客户名字查询计划
	 * @param name 客户名字
	 * @return
	 */
	@Override
	public List<Rehabilitation> findByName(String name) {
		
		return rehabilitationRepository.findByName(name);
	}

	/**
	 * 根据编号删除
	 * @param id
	 */
	@Override
	public void delete(Integer id) {
		rehabilitationRepository.deleteById(id);
		
	}

}
